package com.ray.common.utils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 通用接口返回类
 **/
@Data
public class Result implements Serializable {

    @ApiModelProperty(value = "返回码")
    private int code;
    @ApiModelProperty(value = "消息描述")
    private String msg;
    @ApiModelProperty(value = "消息体")
    private Object data;

    public static Result error(String msg)
    {
        return new  Result(500,msg,null);
    }

    public static Result error()
    {
        return new  Result(500,"操作错误",null);
    }
    public static Result error(int code,String msg)
    {
        return new  Result(code,msg,null);
    }
    public static Result success(Object data)
    {
        return new  Result(200,"请求成功！",data);
    }
    public static Result success(String msg,Object data)
    {
        return new  Result(200,msg,data);
    }
    public static Result success(String msg)
    {
        return new  Result(200,msg,null);
    }
    public static Result forbidden()
    {
        return new  Result(403,"登录超时！",null);
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


}
